; *** 8 Queens
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate
 ("Six Queens Problem" "6皇后谜题")
 ("Eight Queens Problem" "8皇后谜题")
 ("Sixteen Queens Problem" "16皇后谜题")
 ("Ten Maharajas Problem" "10亚马逊谜题")
 ("Maximal Knights" "放马谜题")
)


(define scan
	(while (empty? $1) $1)
	(verify (not-friend? $1))
	(go from)
)

(define scan2
	(set-flag first? true)
	(while (on-board? $1)
		$1
		(if not-empty? (verify (flag? first?)) (set-flag first? false))
	)
	(go from)
	(while (on-board? (opposite $1))
		(opposite $1)
		(if not-empty? (verify (flag? first?)) (set-flag first? false))
	)
	(go from)
)

(define Board-Definitions
  (image "images\Chess\SHaag\Chess8x8.bmp" "images\Chess\Chess8x8.bmp")
  (grid
     (start-rectangle 5 5 53 53)
     (dimensions
         ("a/b/c/d/e/f/g/h" (49 0)) ; files
         ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
     )
     (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
     )
  )
)

(game
   (title "Six Queens Problem")
   (solution "Solutions\8_Queens\Six_Queens_Problem.zsg")
   (description "本关目标：把6个皇后放在6x6棋盘上，任何两个皇后不得处于同一横、直、斜线上。\\这是8皇后问题的简化版。")
   (history "著名的8皇后问题最初由Max Bezzel 1848年提出。高斯（Gauss）于1850年对其进行了分析
             \同年，Franz Nauck发表了6皇后问题的12种基本解，而后该解法被J.W.Glaisher于1874年证明是完全的，即通过旋转和轴对称变换能够形成所有的解形。
             \20世纪初，8皇后问题已经成为一个火热的谜题。随着计算机的发展，8皇后也应用于计算机科学方面。")
   (strategy "两个皇后符合要求的最近距离是马步，而且必然会占满六个行和六个列。
             \6皇后问题解法只有一个基本型（经过旋转和轴对称变换能变成其他解型）
             \\点击“显示答案”可以查看解法。")
   (players White)
   (turn-order White)
   (board
	  (image "images\Chess\SHaag\Chess6x6.bmp" "images\Chess\Chess6x6.bmp")
	  (grid
		 (start-rectangle 5 5 53 53)
		 (dimensions
			 ("a/b/c/d/e/f" (49 0)) ; files
			 ("6/5/4/3/2/1" (0 49)) ; ranks
		 )
		 (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
					 (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
		 )
	  )
   )
   (board-setup (White (Queen off 16)))
   (piece
      (name Queen)
	  (help "任何两个皇后不得处于同一条直线或斜线！")
      (description "你只能把皇后放在横、直、斜线上没有其他皇后的位置。")
      (image White "images\Chess\SHaag\wqueen.bmp" "images\Chess\wqueen.bmp")
      (drops (
		(verify empty?)
		(scan n) (scan ne) (scan e) (scan se) (scan s) (scan sw) (scan w) (scan nw) (scan n)
		add
      ))
   )
   (win-condition (White) (pieces-remaining 6))
   (loss-condition (White) stalemated)
)

(variant
   (title "Eight Queens Problem")
   (solution "Solutions\8_Queens\Eight_Queens_Problem.zsg")
   (description "本关目标：把8个皇后放在8x8棋盘上，任何两个皇后不得互相攻击，即不能处于同一横、直、斜线上。")
   (history "著名的8皇后问题最初由Max Bezzel 1848年提出。高斯（Gauss）于1850年对其进行了分析
             \同年，Franz Nauck发表了6皇后问题的12种基本解，而后该解法被J.W.Glaisher于1874年证明是完全的，即通过旋转和轴对称变换能够形成所有的解形。
             \20世纪初，8皇后问题已经成为一个火热的谜题。随着计算机的发展，8皇后也应用于计算机科学方面。")
   (strategy "两个皇后间距最近只能是马步，所以马步间隔落子可能是最好的突破口。\8皇后问题基本解形有12种，通过旋转和轴对称变换，所有的解一共是92种。
	\\点击“显示答案”可以查看解法。")
   (board (Board-Definitions))
   (board-setup (White (Queen off 16)))
   (win-condition (White) (pieces-remaining 8))
   (loss-condition (White) stalemated)
)

(variant
   (title "Sixteen Queens Problem")
   (solution "Solutions\8_Queens\Sixteen_Queens_Problem.zsg")
   (description "本关目标：把16个皇后放在8x8棋盘上，任何一条横线、纵线和斜线上不得有多于两个皇后存在。")
   (strategy "提示：实际上每条线恰好两个皇后才是最终解。\\点击“显示答案”可以查看其中的一种解法。")
   (board (Board-Definitions))
   (piece
      (name Queen)
	  (help "任何一条线上的皇后不能超过两个！")
     (description "后\如果那一条线上有两个皇后，你就不能再往那条线上放子了。")
      (image White "images\Chess\SHaag\wqueen.bmp" "images\Chess\wqueen.bmp")
      (drops (
		(verify empty?)
		(scan2 n) (scan2 ne) (scan2 e) (scan2 se)
		add
      ))
   )
   (win-condition (White) (pieces-remaining 16))
   (loss-condition (White) stalemated)
)

(variant (title "-"))

(variant
   (title "Ten Maharajas Problem")
   (solution "Solutions\8_Queens\Ten_Maharajas_Problem.zsg")
   (description "本关目标：把10个亚马逊放在10x10棋盘上，任何两个亚马逊之间不得互相攻击。\\亚马逊的走法是后+马，也就是说，两个亚马逊不得处于同一横、直、斜线上，也不得成日字。")
   (history "亚马逊谜题最初由Martin Gardner提出。他还证明了对于小于10x10的棋盘，这个谜题是无解的。")
   (strategy "这个谜题只有唯一基本解。点击“显示答案”可以查看解法。")
   (board
	  (image "images\Chess\SHaag\Chess10x10.bmp" "images\Chess\Chess10x10.bmp")
	  (grid
		 (start-rectangle 5 5 53 53)
		 (dimensions
			 ("a/b/c/d/e/f/g/h/i/j" (49 0)) ; files
			 ("10/9/8/7/6/5/4/3/2/1" (0 49)) ; ranks
		 )
		 (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
					 (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
					 (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
					 (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
		 )
	  )
   )
   (piece (name Queen))
   (piece
      (name Maharaja)
      (image White "images\Chess\SHaag\Maharaja.bmp" "images\Chess\Maharaja.bmp")
 	  (help "注意亚马逊可以走八个方向以外，还能走日字。")
      (description "亚马逊\你不能把亚马逊放到其他亚马逊的控制范围内。")
      (drops (
		(verify empty?)
		(scan n) (scan ne) (scan e) (scan se) (scan s) (scan sw) (scan w) (scan nw) (scan n)
        (if (or (friend? nnw) (friend? nne) (friend? ene) (friend? ese)
		        (friend? sse) (friend? ssw) (friend? wsw) (friend? wnw)
			)
		    (verify false) ; break
		)
		add
      ))
   )
   (board-setup (White (Maharaja off 10)))
   (win-condition (White) (pieces-remaining 10 Maharaja))
   (loss-condition (White) stalemated)
)

(variant
   (title "Maximal Knights")
   (solution "Solutions\8_Queens\Maximal_Knights.zsg")
   (description "本关目标：把32个马放在8x8棋盘上，任何两个马间不得互相攻击。")
   (strategy "先不要点击“查看答案”，想一个问题：\马移动前后是不是一定会换棋格的颜色？\\其实，这关才是最简单的吧。。。")
   (board
	 (image "images\Chess\SHaag\Chess8x8.bmp" "images\Chess\Chess8x8.bmp")
	 (grid
	   (start-rectangle 5 5 53 53)
	   (dimensions
		 ("a/b/c/d/e/f/g/h" (49 0)) ; files
		 ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
	   )
       (directions (nnw -1 -2) (nne  1 -2) (ene  2 -1) (ese  2  1)
	               (sse  1  2) (ssw -1  2) (wsw -2  1) (wnw -2 -1)
       )
	 )
   )
   (board-setup (White (Knight off 32)))
   (piece
      (name Knight)
	  (help "任何两个马不得互相攻击。")
      (description "马\你无法把马放入其他马的攻击范围。")
      (image White "images\Chess\SHaag\wknight.bmp" "images\Chess\wknight.bmp")
      (drops (
		(verify empty?)
        (if (or (friend? nnw) (friend? nne) (friend? ene) (friend? ese)
		        (friend? sse) (friend? ssw) (friend? wsw) (friend? wnw)
			)
		    (verify false) ; break
		)
		add
      ))
   )
   (piece (name Queen))
   (win-condition (White) (pieces-remaining 32 Knight))
   (loss-condition (White) stalemated)
)
